import type { AxiosInstance } from "axios";
import axios from "axios";

const service: AxiosInstance = axios.create({
  baseURL: import.meta.env.VITE_BASE_API,
  timeout: 1000 * 20,
  headers: {
    "Content-Type": "application/x-www-form-urlencoded"
  }
});
service.interceptors.response.use((result) => {
  if (result.status===200 && result.data.code===200){
    return result.data
  }else {
    return Promise.reject(result);
  }
})
export const getAreaList = (params?: object) => {
  return service({ url: "/api/v2/home/area/list", method: "get", params });
};
export const applyService = (data?: object) => {
  return service({ url: "/api/v2/home/applyService", method: "post", data });
};
export const applyMerchant = (data?: object) => {
  return service({ url: "/api/v2/home/applyMerchant", method: "post", data });
};
export const getSellerList = (params?: object) => {
  return service({ url: "/api/v2/home/sellerList", method: "get", params });
};
export const getMessageList = (params?: object) => {
  return service({ url: "/api/v2/information/industryNewsList", method: "get", params });
};
export const getArticleInfo = (params?: object) => {
  return service({ url: "/api/v2/information/industryNewsInfo", method: "get", params });
};
export const getVersionList = (params?: object) => {
  return service({ url: "/api/v2/home/appVersion/list", method: "get", params });
};
